
R version 2.9.2 (2009-08-24)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> kamatlab<<-0.08
> volatilitas=0.23
> dt=1/360
> t_t=0.25
> n=trunc(t_t/dt)
> s<-c()
> x<-680
> f<-c()
> uj=c()
> epszilon<-c()
> MonteCarlo<-function(elemszam){ 
+ for (i in 1:elemszam){
+ epszilon<-rnorm(n,0,1) 
+ 
+ s[1]<-661
+ for (j in 1:(n-1)){
+ uj<<-(kamatlab-0.5*volatilitas^2)*dt+volatilitas*sqrt(dt)*epszilon[j]
+ s[j+1]<-s[j]*exp(uj)
+ }
+ f[i]<-max(0,x-min(s)) 
+ 
+  }
+ atlag<-mean(f) 
+ 
+ opciosdij=(exp(-kamatlab*t_t)*atlag)
+ opciosdij} 
> 
> MonteCarlo(1000)
[1] 66.80998
> MonteCarlo(5000)
[[1] 67.68498
> MonteCarlo(20000)
[1] 66.26012
 > MonteCarlo(30000)
[1] 66.09388
> 
> 
